package com.example.day08;

import java.io.*;

public class Test {
    public static void main(String[] args) {
        try {
            InputStream inputStream = new FileInputStream("d:/test.txt");
//            System.out.println(inputStream.available());
//            System.out.println(inputStream.read());
            byte[] bytes = new byte[4];
            System.out.println(inputStream.read(bytes));


            // 调用 inputStream 的第 3 个 read 方法，输出字母 s

//            byte[] bytes1 = new byte[3];
//            int offset = 0, length = 3;
//            inputStream.read(bytes1, offset, length);
//            System.out.println((char)bytes1[2]);

            // 从文件 test.txt 中读取内容，写入 demo.txt
            OutputStream outputStream = new FileOutputStream("D:/demo.txt");
            for (byte aByte : bytes) { // [-128, 127] ASCII [0, 127]
                outputStream.write(aByte);
            }
//            outputStream.close();

//            Reader reader = new FileReader("D:/test.txt");
//            Writer writer = new FileWriter("d:/demo.txt");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

class Demo {
    public void m() {

    }

    public static void main(String[] args) {
        Demo demo = new Demo();
        demo.m();
    }
}
